<template>
  <div>
    <van-nav-bar left-text="返回" right-text="确定" @click-left="$emit('close') " @click-right="onConfirm" />
    <van-field v-model="message.name" placeholder="请输入内容" />
  </div>
</template>
<script>
import { updateProfile } from '@/api/user.js'
import { mapState } from 'vuex'
export default {
  props: {
    value: {
      type: Object,
      required: true
    },
    data() {
      return {
        message: this.value
      }
    },
    methods: {
      async onConfirm() {
        this.$toast.loading({ message: '发布中...', forbidClick: true })
        const { data: res } = await updateProfile(this.profile.id, this.message)
        if (res.code === 200) {
          console.log(res)
          this.$toast.success('修改成功')
          this.$emit('close')
        }
      }
    },
    computed: {
      ...mapState(['profile'])
    }
  }
}
</script>
<style lang="less" scoped>
.van-cell {
  background: unset;
}
/deep/.van-field__control {
  height: 46px;
  background: #fff;
  font-size: 16px;
}
</style>
